using System;
using System.IO;

using Gtk;

namespace gtkGui
{
	public partial class CompileDialog : Gtk.Dialog
	{
		public CompileDialog()
		{
			this.Build();
		}
        
        public bool Embed {
            get { return embed.Active; }
        }
        public bool Comments {
            get { return comments.Active; }
        }
        public bool EOF {
            get { return eof.Active; }
        }
        public bool IntArray {
            get { return intArray.Active; }
        }
        public string Filename {
            get {
                string path = System.IO.Path.Combine(folder.Filename, name.Text);
                path = System.IO.Path.ChangeExtension(path, ".exe");
                Console.WriteLine(path);
                return path;
            }
        }

		protected virtual void OnCompileClicked(object sender, System.EventArgs e)
		{
            Respond(Gtk.ResponseType.Accept);
        }
		protected virtual void OnCancelClicked(object sender, System.EventArgs e)
		{
            Respond(Gtk.ResponseType.Cancel);
		}

		protected virtual void OnNameChanged(object sender, System.EventArgs e)
		{
            compile.Sensitive = name.Text != "";
		}
        private bool prepare_tailor;
        private bool tailor;

		protected virtual void OnExpanderSizeAllocated(object o, Gtk.SizeAllocatedArgs args)
		{
            if(prepare_tailor) {
                prepare_tailor = false;
                tailor = true;
            }
		}

		protected virtual void OnExpanderActivated(object sender, System.EventArgs e)
		{
            Expander expander = sender as Expander;
            if(!expander.Expanded) {
                prepare_tailor = true;
            }
		}

		protected virtual void OnExpanderExposeEvent(object o, Gtk.ExposeEventArgs args)
		{
            if(tailor) {
                int width, height;
                GetSize(out width, out height);
                Resize(width, DefaultHeight);
                tailor = false;
            }
		}
	}
}
